<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let dzx = new Promise(() => {
        resolve("成功");
      });

      class Lb {
        //定义promise的三种状态
        static pending = "pending";
        static fulfilled = "fulfilled";
        static rejected = "rejected";
        constructor(callback) {
          this.statu = "pending";
          //传入值为回调函数
          this.value = null;
          this.callback = callback;
          this.callbackList = [];
        }

        //定义方法resolve
        resolve = (value) => {
          //只有在状态为pending时才能改变状态
          if (this.statu === "pending") {
            this.value = value;
            this.statu = Lb.fulfilled;
          }
        };
      }
    </script>
  </body>
</html>
